package org.vic.observer.observer;

import java.util.HashMap;
import java.util.Map;

/**
 * 管理器，保持一份独有的作者列表
 * Created by VIC.Huang on 2016/8/23.
 */
public class WriterManager {
    private Map<String, Writer> writerMap = new HashMap<String, Writer>();

    // 添加作者
    public void addWriter(Writer writer) {
        writerMap.put(writer.getName(), writer);
    }

    // 获取作者
    public Writer getWriter(String writerName) {
        return writerMap.get(writerName);
    }

    // 单例
    private WriterManager() {}
    private static class WriterManagerInstance {
        private static WriterManager instance = new WriterManager();
    }

    public static WriterManager getInstance() {
        return WriterManagerInstance.instance;
    }
}
